package com.example.controller;

import com.example.domain.Course;
import com.example.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    // 添加课程信息的接口
    @PostMapping("/add")
    public ResponseEntity<String> addCourse(@RequestBody Course course) {
        boolean result = courseService.addCourse(course);
        if (result) {
            return ResponseEntity.ok("课程信息添加成功！");
        } else {
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("课程信息添加失败！");
        }
    }
}
